#include <iostream>
#include <vector>
using namespace std;

void moveToEnd(vector<int>& nums, int target) {
    int i = 0, j = 0;
    while (j < nums.size()) {
        if (nums[j] != target) {
            swap(nums[j], nums[i]);
            i++;
        }
        j++;
    }
}

int main() {
    int n, target;
    cout << "请输入一个正整数 n (n<=100)：";
    cin >> n;
    vector<int> nums(n);
    cout << "请输入 " << n << " 个整数：";
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    cout << "请输入目标数 target：";
    cin >> target;
    moveToEnd(nums, target);
    cout << "移动后的数组：";
    for (int num : nums) {
        cout << num << " ";
    }
    cout << endl;
    return 0;
}